import Observer from './observer'

export default class ObserverManage {
  constructor(dataInterfaceList) {
    this.observerIdMap = {}
    dataInterfaceList && dataInterfaceList.forEach(one => {
      this.observerIdMap[one.id] = new Observer(one)
    })
  }

  get(id) {
    if (this.observerIdMap[id]) {
      return this.observerIdMap[id]
    } else {
      let observer = new Observer({ id, isCache: false })
      this.observerIdMap[id] = observer
      return observer
    }
  }
}
